package com.ruoyi.system.mapper;

import java.util.List;
import com.ruoyi.system.domain.SysNotice;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 公告 数据层
 * 
 * @author ruoyi
 */
public interface SysNoticeMapper
{
    /**
     * 查询公告信息
     * 
     * @param noticeId 公告ID
     * @return 公告信息
     */
    @Results(id="notice",
            value={
                @Result(id=true,property="noticeId", column="notice_id"),
                @Result(property="noticeTitle", column="notice_title"),
                @Result(property="noticeType", column="notice_type"),
                @Result(property="noticeContent", column="notice_content"),
                @Result(property="status", column="status"),
                @Result(property="createBy", column="create_by"),
                @Result(property="createTime", column="create_time"),
                @Result(property="updateBy", column="update_by"),
                @Result(property="updateTime", column="update_time"),
                @Result(property="remark", column="remark")
    })
    @Select("select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, " +
            "create_by, create_time, update_by, update_time, remark from sys_notice where notice_id = #{noticeId}")
    public SysNotice selectNoticeById(Long noticeId);

    /**
     * 查询公告列表
     * 
     * @param notice 公告信息
     * @return 公告集合
     */
    @ResultMap("notice")
    @Select("<script>select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, " +
            "status, create_by, create_time, update_by, update_time, remark from sys_notice " +
            "<where>" +
            "<if test=\"noticeTitle != null and noticeTitle != ''\"> " +
            "AND notice_title like concat('%', #{noticeTitle}, '%') </if> " +
            "<if test=\"noticeType != null and noticeType != ''\">" +
            "AND notice_type = #{noticeType} </if>" +
            "<if test=\"createBy != null and createBy != ''\">" +
            "AND create_by like concat('%', #{createBy}, '%') </if>" +
            "</where></script>")
    public List<SysNotice> selectNoticeList(SysNotice notice);

    /**
     * 新增公告
     * 
     * @param notice 公告信息
     * @return 结果
     */
    public int insertNotice(SysNotice notice);

    /**
     * 修改公告
     * 
     * @param notice 公告信息
     * @return 结果
     */
    public int updateNotice(SysNotice notice);

    /**
     * 批量删除公告
     * 
     * @param noticeIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteNoticeByIds(String[] noticeIds);
}